package com.zisuyi.uilibrary.view

import android.view.MotionEvent
import android.view.View

interface IClickScale {

    fun onTouchEventHelper(view: View, event: MotionEvent?) {
        view.apply {
            if (isClickable) {
                event?.let {
                    when (event.action) {
                        MotionEvent.ACTION_DOWN -> {
                            animate().cancel()
                            animate().setDuration(80).scaleX(0.9f).scaleY(0.9f).start()
                        }
                        MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
                            animate().cancel()
                            animate().setDuration(50).scaleX(1f).scaleY(1f).start()
                        }
                    }
                }
            }
        }
    }

}